package com.itbaizhan.shopping_goods_service.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itbaizhan.shopping_common.pojo.SeckillGoods;
import com.itbaizhan.shopping_common.service.SeckillGoodsService;
import com.itbaizhan.shopping_goods_service.mapper.SeckillMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 秒杀商品服务实现类
 */
@DubboService
@Transactional
@Service
public class SeckillGoodsServiceImpl implements SeckillGoodsService {
	
	@Autowired
	private SeckillMapper seckillMapper;
	
	/**
	 * 添加秒杀商品
	 *
	 * @param seckillGoods 秒杀商品实体
	 */
	public void add(SeckillGoods seckillGoods) {
		seckillMapper.insert(seckillGoods);
	}
	
	/**
	 * 修改秒杀商品
	 *
	 * @param seckillGoods 秒杀商品实体
	 */
	public void update(SeckillGoods seckillGoods) {
		seckillMapper.updateById(seckillGoods);
	}
	
	/**
	 * 查询秒杀商品
	 *
	 * @param page 页数
	 * @param size 每页条数
	 * @return
	 */
	public Page<SeckillGoods> findPage(int page, int size) {
		return seckillMapper.selectPage(new Page<>(page, size), null);
	}
}
